package com.yb.xczx.cloud.auth.entity;

import com.alibaba.fastjson2.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.time.LocalDateTime;
import java.util.Collection;

import com.fasterxml.jackson.annotation.JacksonAnnotation;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

/**
 * <p>
 * 
 * </p>
 *
 * @author 姚兵
 * @since 2023-05-17
 */
@Getter
@Setter
@TableName("sys_user")
@ApiModel(value = "SysUser对象", description = "")
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
public class SysUser {

    @ApiModelProperty("主键")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty("系统分配")
    @TableField("user_id")
    private Integer userId;

    @ApiModelProperty(" 用户名")
    @TableField("username")
    private String username;

    @ApiModelProperty("密码")
    @TableField("password")
    private String password;

    @ApiModelProperty("加密方式 1 Bcrpt")
    @TableField("encrypted_type")
    private String encryptedType;

    @ApiModelProperty("是否启用 0 未启用 1 启用")
    @TableField("enabled")
    private Integer enabled;

    @ApiModelProperty("是否过期 0 过期 1未过期")
    @TableField("account_non_expired")
    private Integer accountNonExpired;

    @ApiModelProperty("是否被锁定 0 被锁定 1 未被锁定")
    @TableField("account_non_locked")
    private Integer accountNonLocked;

    @ApiModelProperty("密码是否过期 0 过期 1未过期")
    @TableField("credentials_non_expired")
    private Integer credentialsNonExpired;

    @ApiModelProperty("创建时间")
    @TableField("create_time")
    private LocalDateTime createTime;

    @ApiModelProperty("更新时间")
    @TableField("update_time")
    private LocalDateTime updateTime;

    public boolean isEnabled(){
        return enabled==1;
    }

    public boolean isAccountNonExpired() {
        return accountNonExpired==1;
    }

    public boolean isAccountNonLocked() {
        return accountNonLocked==1;
    }

    public boolean isCredentialsNonExpired() {
        return credentialsNonExpired==1;
    }
}
